package com.ygg.cps.afx.jdbc.intf ;

import java.util.List;
import java.util.Map;

import com.ygg.cps.afx.exception.DaoException;
import com.ygg.cps.afx.jdbc.QueryParam;

/**
 * jdbc操作的公用的方法
 * 
 * @author lihc
 *
 * @param <T>
 */
public interface BaseDaoIF<T>
{
    
    /**
     * 修改和删除方法
     * 
     * @param sql
     * @param params
     * @return
     * @throws DaoException
     */
    public int execute(String sql, List<QueryParam> params)
        throws DaoException;
    
    public int execute(String sql, Object[] params)
        throws DaoException;
    
    /**
     * 新增方法
     * 
     * @param sql
     * @param params
     * @return
     * @throws DaoException
     */
    public int insert(String sql, List<QueryParam> params)
        throws DaoException;
    
    public int insert(String sql, Object[] params)
        throws DaoException;
    
    /**
     * 批量新增,　要放在一个事务中　　
     * 
     * @param sql
     * @param paramArray
     * @return
     * @throws DaoException
     */
    public int[] insertBatch(String sql, List<QueryParam>[] paramArray)
        throws DaoException;
    
    /**
     * 批量修改和删除,　要放在一个事务中
     * 
     * @param sqlArray
     * @param paramArray
     * @return
     * @throws DaoException
     */
    public int[] executeBatch(String[] sqlArray, List<QueryParam>[] paramArray)
        throws DaoException;
    
    public List<T> queryForT(String sql, List<QueryParam> params, Class<T> type)
        throws DaoException;
    
    public List<T> queryForT(String sql, Object[] params, Class<T> type)
        throws DaoException;
    
    public List<T> queryForT(String sql, Class<T> type)
        throws DaoException;
    
    public T queryForOneT(String sql, List<QueryParam> params, Class<T> type)
        throws DaoException;
    
    public T queryForOneT(String sql, Object[] params, Class<T> type)
        throws DaoException;
    
    /**
     * 根据BeanHandler去转成一个Bean
     * 
     * @param sql
     * @param params
     * @param type
     * @return
     * @throws DaoException
     */
    @Deprecated
    public T queryForBean(String sql, Object params[], Class<T> type)
        throws DaoException;
    
    /**
     * 自定义一个ResultSetHandler,去转化成一个Bean
     * 
     * @param sql
     * @param params
     * @param rsh
     * @return
     * @throws DaoException
     */
    @Deprecated
    public T queryForBean(String sql, Object params[], ResultSetHandler rsh)
        throws DaoException;
    
    /**
     * 根据BeanListHandler去转成一个Bean
     * 
     * @param sql
     * @param params
     * @param type
     * @return
     * @throws DaoException
     */
    @Deprecated
    public List<T> queryForBeans(String sql, Object params[], Class<T> type)
        throws DaoException;
    
    /**
     * 自定义一个ResultSetHandler,去转化成一个Bean
     * 
     * @param sql
     * @param params
     * @param rsh
     * @return
     * @throws DaoException
     */
    @Deprecated
    public List<T> queryForBeans(String sql, Object params[], ResultSetHandler rsh)
        throws DaoException;
    
    public T queryForOneT(String sql, Class<T> type)
        throws DaoException;
    
    public List<Integer> queryForInteger(String sql, List<QueryParam> params)
        throws DaoException;
    
    public List<Integer> queryForInteger(String sql, Object[] params)
        throws DaoException;
    
    public List<Integer> queryForInteger(String sql)
        throws DaoException;
    
    public int queryOneId(String sql, List<QueryParam> params)
        throws DaoException;
    
    public int queryOneId(String sql, Object[] params)
        throws DaoException;
    
    public int queryOneId(String sql)
        throws DaoException;
    
    public List<Map<String, Object>> queryForMap(String sql, List<QueryParam> params)
        throws DaoException;
    
    public List<Map<String, Object>> queryForMap(String sql, Object[] params)
        throws DaoException;
    
    public List<Map<String, Object>> queryForMap(String sql)
        throws DaoException;
    
    public Map<String, Object> queryForOneMap(String sql, List<QueryParam> params)
        throws DaoException;
    
    public Map<String, Object> queryForOneMap(String sql, Object[] params)
        throws DaoException;
    
    public Map<String, Object> queryForOneMap(String sql)
        throws DaoException;
    
    /**
     * 批量查询，返回一个Bean
     * 
     * @param sqlArray
     * @param paramArray
     * @return
     * @throws DaoException
     */
    public List<T>[] queryBatch2T(String[] sqlArray, List<QueryParam>[] paramArray, Class<T> type)
        throws DaoException;
    
    /**
     * 批量查询，返回一个 List<Map<String, Object>>
     * 
     * @param sqlArray
     * @param paramArray
     * @return
     * @throws DaoException
     */
    public List<Map<String, Object>>[] queryBatch2Map(String[] sqlArray, List<QueryParam>[] paramArray)
        throws DaoException;
}
